import random

from PyQt5.QtCore import QPoint, QSize
from PyQt5.QtGui import QPainter, QPen, QColor, QFont, QImage


# 俄罗斯方块里面那个具体的块
class Rectangle:
    # xy是方块的相对位置
    def __init__(self, x: int, y: int):
        self.x = x
        self.y = y
        self.image = QImage(QSize(20, 20), QImage.Format.Format_ARGB32)

        self.image.fill(QColor(random.randint(0, 150), random.randint(0, 150), random.randint(0, 150), 255))
        # self.image.fill(QColor(0, 0, 0))

    def get_absolute_position(self) -> QPoint:
        return QPoint(self.x * 23 + 3, self.y * 23 + 3)

    def setXY(self, x: int, y: int):
        self.x = x
        self.y = y

    def show(self) -> QImage:
        return self.image
